require(['../config/requireconfig'],function(config){
	//根据需要添加
	require(['zepto','common/mcommon','common/prodFeedBack'],function($,com,feedBack){
		com.init();
		feedBack.init();
		var pageLogic = new PageLogic($,com);
		pageLogic.init();

	});
});
var PageLogic = function($,com){
	
	return{
		init:function(){
			var _this = this;
			_this.initMbCd();
		},
		initMbCd:function(){
			var _this = this;
			com.ajax({
				url:"/getMdCd.json",
				success:function(res){
					_this.genItems(res.data.cd);
				}
			})
		},
		genItems:function(cds){
			var html = "";
			var _this = this;
			_this.cds = cds;
			$(cds).each(function(idx,tg){
				html += '<li class="item" tg="' + idx + '"> ';
				html += '	<div  class="icon"><img src="/mb/frontlib/img/ICON/' + this.image + '"></div> ';
				html += '	<span>' + this.lineName + '</span> ';
				html += '	<i class="icon-dir"></i> ';
				html += '</li> ';
			});
			$("#items").html(html);
			_this.bindEvent();
		},
		bindEvent:function(){
			var _this = this;
			$("#items").find("li").on("click",function(){
				var idx = $(this).attr("tg");
				var cdInfo = _this.cds[idx];
				_this.showBrandBlock(cdInfo);
			});
			$(".brandtool").on("click",function(){
				$(".carType").fadeOut();
			});
		},
		showBrandBlock:function(cdInfo){
			var _this = this;
			$("#brandName").text(cdInfo.lineName);
			var html = "";
			$(cdInfo.names).each(function(){
				html += '<li class="cartype" tg="' + this.name + '" >' + this.value + '<i class="iconfont dir"></i></li>';
			});
			$(".carType").find(".cartypes").html(html);
			$(".carType").find(".cartypes").find("li").on("click",function(){
				var modelName = $(this).attr("tg");
				com.utils().windowJump("prodTeam2.htm?sublineNo=" + modelName);
			});
			$(".carType").fadeIn();
		},
	}
}